<template>
    <div>
        <el-tabs v-model="currentPrintTab" class="center-tabs" >
            <el-tab-pane label="现金报销单" name="main" />
            <el-tab-pane label="报销明细" name="mx" />
            <el-tab-pane v-if="hasCf" label="餐费报销" name="cf" />
            <el-tab-pane v-if="hasJb" label="加班餐费" name="jb" />
            <el-tab-pane v-for="file in itemFileList" :key="file.fileId" :name="''+file.fileId" :label="file.name"/>
        </el-tabs>
        <el-scrollbar class="right-scrollbar">
            <el-form v-show="currentPrintTab==='main'"> 
            <div id="mainPrintDiv">
                <div style="width:270px;height:22px;font-size:18px;font-family:'黑体';margin:0 auto;">中国软件与技术服务股份有限公司</div>
                <div style="width:100px;height:30px;font-size:18px;font-family:'黑体';margin:0 auto;">现金报销单</div>
                <table style="width:95%;margin:0 auto;"  cellspacing="0" cellpadding="0" >
                <tr v-bind="printBasicData">
                    <td colspan="3" class="main-print-col12">&nbsp;部门名称：{{printBasicData.deptNamePrint}}</td>
                    <td align="right" class="main-print-col12">报销日期：&nbsp;
                    {{ printBasicData.expenseTimeYearPrint }}&nbsp;年&nbsp;
                    {{ printBasicData.expenseTimeMonPrint }}&nbsp;月&nbsp;
                    {{ printBasicData.expenseTimeDayPrint }}&nbsp;日&nbsp;
                    </td>
                </tr>
                <tr>
                    <td class="main-print-col12 textCenterPrint main-print-border-top-left" style="height:40px;">姓名</td>
                    <td class="main-print-col12 textCenterPrint main-print-border-top-left">{{ printBasicData.expenseNamePrint }}</td>
                    <td class="main-print-col12 textCenterPrint main-print-border-top-left">时间</td>
                    <td class="main-print-col12 textCenterPrint main-print-border-top-left main-print-border-right">从&nbsp;{{ printBasicData.cashTimeStartYearPrint }}&nbsp;年
                    &nbsp;{{ printBasicData.cashTimeStartMonPrint }}&nbsp;月&nbsp;{{ printBasicData.cashTimeStartDayPrint }}&nbsp;日至&nbsp;{{ printBasicData.cashTimeEndYearPrint }}&nbsp;年
                    &nbsp;{{ printBasicData.cashTimeEndMonPrint }}&nbsp;月&nbsp;{{ printBasicData.cashTimeEndDayPrint }}&nbsp;日共&nbsp;{{cashTimeLength}}&nbsp;日
                    </td>
                </tr>
                <tr>
                    <th class="main-print-col12 textCenterPrint main-print-border-top-left " width="10%">报销内容</th>
                    <th class="main-print-col12 textCenterPrint main-print-border-top-left" width="20%" >单据张数</th>
                    <th class="main-print-col12 textCenterPrint main-print-border-top-left" width="10%">金额</th>
                    <th class="main-print-col12 textCenterPrint main-print-border-top-left main-print-border-right" width="60%">备注</th>
                </tr>
                <tr v-for="(item, index) in printMainList" :key="index">
                    <td class="main-print-col12 textCenterPrint main-print-border-top-left">{{item.expenseContentName}}</td>
                    <td class="main-print-col12 textCenterPrint main-print-border-top-left" >{{item.invoiceNum}}</td>
                    <td class="main-print-col12 textCenterPrint main-print-border-top-left" v-if="item.expenseMoney===''"></td>
                    <td class="main-print-col12 textCenterPrint main-print-border-top-left" v-else>¥{{item.expenseMoney}}</td>
                    <td class="main-print-col12 textCenterPrint main-print-border-top-left main-print-border-right">{{item.costTimeStr}}</td>
                </tr>
                <tr v-bind="printBasicData">
                    <td class="main-print-col12 textCenterPrint main-print-border-top-left main-print-border-bottom" >合&nbsp;计</td>
                    <td class="main-print-col12 textCenterPrint main-print-border-top-left main-print-border-bottom">{{printBasicData.invoiceNumPrint}}</td>
                    <td class="main-print-col12 textCenterPrint main-print-border-top-left main-print-border-bottom" v-if="printBasicData.totalAmount">¥{{printBasicData.totalAmount}}</td>
                    <td class="main-print-col12 textCenterPrint main-print-border-top-left main-print-border-bottom" v-else></td>
                    <td class="main-print-col12 textCenterPrint main-print-border-top-left main-print-border-bottom main-print-border-right">{{printBasicData.expenseMoneyDxPrint}}</td>
                </tr>
                </table>
                <div style="width:94%;margin:0 auto;">
                <div class="printBottomMainDiv" style="width:40%;">公司领导：</div>
                <div class="printBottomMainDiv" style="width:40%;">部门领导：</div>  
                <div class="printBottomMainDiv" style="width:20%;">报销人：</div>
                </div>
            </div>
            </el-form>
            <el-form v-show="currentPrintTab==='mx'"> 
            <div id="mxPrintDiv">
                <div style="width:356px;height:40px;font-size:23px;font-family:'宋体';font-weight:bold;margin:0 auto;letter-spacing:1px;">{{ printBasicData.deptNamePrint }}报销明细表</div>
                <table style="width:96%;margin:0 auto;" cellspacing="0" cellpadding="0" border="1">
                <tr v-bind="printBasicData">
                    <td class="main-print-col16 textCenterPrint main-print-border-top-left" colspan="2">报销人归属部门：</td>
                    <td class="main-print-col16 textLeftPrint main-print-border-top-left"  colspan="2" >{{ printBasicData.deptNamePrint }}</td>
                    <td class="main-print-col16 textCenterPrint main-print-border-top-left">报销人：</td>
                    <td class="main-print-col16 textLeftPrint main-print-border-top-left main-print-border-right">{{ printBasicData.expenseNamePrint }}</td>
                </tr>
                <tr>
                    <td class="main-print-col16 textCenterPrint main-print-border-top-left "  colspan="2">项目名称：</td>
                    <td class="main-print-col16 textLeftPrint main-print-border-top-left"  colspan="2" style="font-size:12px">{{ printBasicData.productNamePrint }}</td>
                    <td class="main-print-col16 textCenterPrint main-print-border-top-left">项目财务编号：</td>
                    <td class="main-print-col16 textLeftPrint main-print-border-top-left main-print-border-right"><!--{{ printBasicData.productFinanceNoPrint }}--></td>
                </tr>
                <tr>
                    <td class="main-print-col16 textCenterPrint main-print-border-top-left "  colspan="2">项目归属部门：</td>
                    <td class="main-print-col16 textLeftPrint main-print-border-top-left"  colspan="2">{{ printBasicData.deptNamePrint }}</td>
                    <td class="main-print-col16 textCenterPrint main-print-border-top-left">报销时间：</td>
                    <td class="main-print-col16 textLeftPrint main-print-border-top-left main-print-border-right">{{ printBasicData.costTimeStart }}至{{ printBasicData.costTimeEnd }}</td>
                </tr>
                <tr>
                    <th class="main-print-col16 textCenterPrint main-print-border-top-left " width="5%">序号</th>
                    <th class="main-print-col16 textCenterPrint main-print-border-top-left" width="18%">报销内容</th>
                    <th class="main-print-col16 textCenterPrint main-print-border-top-left" width="18%">发生时间</th>
                    <th class="main-print-col16 textCenterPrint main-print-border-top-left" width="14%" >单据张数</th>
                    <th class="main-print-col16 textCenterPrint main-print-border-top-left" width="16%">金额</th>
                    <th class="main-print-col16 textCenterPrint main-print-border-top-left main-print-border-right" width="19%">事由</th>
                </tr>
                <tr v-for="(item, index) in printDetailList" :key="index">
                    <td class="main-print-col16 textCenterPrint main-print-border-top-left ">{{index+1}}</td>
                    <td class="main-print-col16 textCenterPrint main-print-border-top-left">{{item.expenseContentName}}</td>
                    <td class="main-print-col16 textCenterPrint main-print-border-top-left" v-if="item.expenseContent == 1">{{item.costTimeStr2}}</td>
                    <td class="main-print-col16 textCenterPrint main-print-border-top-left" v-else>{{item.costTimeStr}}</td>
                    <td class="main-print-col16 textCenterPrint main-print-border-top-left" >{{item.invoiceNum}}</td>
                    <td class="main-print-col16 textCenterPrint main-print-border-top-left">{{item.expenseMoney}}</td>
                    <td class="main-print-col16 textLeftPrint main-print-border-top-left main-print-border-right">{{item.expenseRemark}}</td>
                </tr>
                <tr v-bind="printBasicData">
                    <td class="main-print-col16 textCenterPrint main-print-border-top-left main-print-border-bottom" colspan="2">合&nbsp;计：</td>
                    <td class="main-print-col16 textCenterPrint main-print-border-top-left main-print-border-bottom"></td>
                    <td class="main-print-col16 textCenterPrint main-print-border-top-left main-print-border-bottom">{{printBasicData.invoiceNumPrint}}</td>
                    <td class="main-print-col16 textCenterPrint main-print-border-top-left main-print-border-bottom">{{printBasicData.totalAmount}}</td>
                    <td class="main-print-col16 textCenterPrint main-print-border-top-left main-print-border-right main-print-border-bottom"></td>
                </tr>
                </table>
                <div style="width:96%;margin:0 auto;">
                <div class="printBottomDiv">项目经理签字：</div>
                <div class="printBottomDiv">二级部门经理签字：</div>  
                </div>
            </div>
            </el-form>
            <el-form v-show="currentPrintTab==='cf'"> 
                <div id="cfPrintDiv">
                    <div style="width:250px;height:40px;font-size:16px;font-family:'宋体';font-weight:bold;margin:0 auto;letter-spacing:1px;"> {{ printBasicData.expenseTimeYearPrint }}年（{{ printBasicData.expenseTimeMonPrint }}）月餐费报销说明</div>
                    <table style="width:96%;margin:0 auto;border-bottom:1px solid black;" cellspacing="0" cellpadding="0">
                    <tr>
                        <th class="main-print-col12 textCenterPrint main-print-border-top-left " >序号</th>
                        <th class="main-print-col12 textCenterPrint main-print-border-top-left" >宴请日期</th>
                        <th class="main-print-col12 textCenterPrint main-print-border-top-left" >消费金额</th>
                        <th class="main-print-col12 textCenterPrint main-print-border-top-left"  >消费城市</th>
                        <th class="main-print-col12 textCenterPrint main-print-border-top-left" >饭店名称</th>
                        <th class="main-print-col10 textCenterPrint main-print-border-top-left" >被宴请人员（与电子表填的参与人数一致）</th>
                        <th class="main-print-col12 textCenterPrint main-print-border-top-left" >单位职务</th>
                        <th class="main-print-col12 textCenterPrint main-print-border-top-left" >宴请原因</th>
                        <th class="main-print-col12 textCenterPrint main-print-border-top-left main-print-border-right" >备注</th>
                    </tr>
                    <tr v-for="(item, index) in cfList" :key="index">
                        <td class="main-print-col12 textCenterPrint main-print-border-top-left ">{{index+1}}</td>
                        <td class="main-print-col12 textCenterPrint main-print-border-top-left">{{item.costTime}}</td>
                        <td class="main-print-col12 textCenterPrint main-print-border-top-left">{{item.expenseMoney}}</td>
                        <td class="main-print-col12 textCenterPrint main-print-border-top-left" >{{item.costCity}}</td>
                        <td class="main-print-col12 textCenterPrint main-print-border-top-left">{{item.hotel}}</td>
                        <td class="main-print-col12 textCenterPrint main-print-border-top-left">{{item.bePersonName}}</td>
                        <td class="main-print-col12 textCenterPrint main-print-border-top-left">{{item.position}}</td>
                        <td class="main-print-col12 textCenterPrint main-print-border-top-left">{{item.reasonForDinner}}</td>
                        <td class="main-print-col12 textLeftPrint main-print-border-top-left main-print-border-right"></td>
                    </tr>
                    </table>
                    
                </div>
            </el-form>
            <el-form v-show="currentPrintTab==='jb'"> 
                <div id="jbPrintDiv">
                    <div style="width:300px;height:40px;font-size:14px;font-family:'宋体';font-weight:bold;margin:0 auto;letter-spacing:1px;"> 石家庄项目组加班餐费记录表（石家庄）</div>
                    <table style="width:96%;margin:0 auto;border-bottom:1px solid black;" cellspacing="0" cellpadding="0">
                        <tr>
                            <th class="main-print-col12 textCenterPrint main-print-border-top-left ">{{ printBasicData.cfMon }}月/日</th>
                            <th class="main-print-col12 textCenterPrint main-print-border-top-left ">餐时</th>
                            <th class="main-print-col12 textCenterPrint main-print-border-top-left" v-for="(item, index) in jbPersonList" :key="index">{{item.personName}}</th>
                            <th class="main-print-col12 textCenterPrint main-print-border-top-left">限额合计（元）</th>
                            <th class="main-print-col12 textCenterPrint main-print-border-top-left">实际花费（元）</th>
                            <th class="main-print-col12 textCenterPrint main-print-border-top-left main-print-border-right">备注</th>
                        </tr>
                        <tr v-for="(item, index) in jbList" :key="index">
                            <td class="main-print-col12 textCenterPrint main-print-border-top-left">{{item.costTime2}}</td>
                            <td class="main-print-col12 textCenterPrint main-print-border-top-left">{{item.mealTime}}</td>
                            <td class="main-print-col12 textCenterPrint main-print-border-top-left" v-for="(ite, ind) in jbPersonList" :key="ind" >
                                <span v-if="item.bePersonName.indexOf(ite.personName) != -1">15</span>
                                <span v-else></span>
                            </td>
                            <td class="main-print-col12 textCenterPrint main-print-border-top-left">{{item.xehj}}</td>
                            <td class="main-print-col12 textCenterPrint main-print-border-top-left">{{item.expenseMoney}}</td>
                            <td class="main-print-col12 textLeftPrint main-print-border-top-left main-print-border-right"></td>
                        </tr>
                        <tr>
                            <td class="main-print-col12 textCenterPrint main-print-border-top-left" style="border-right: 0px;"></td>
                            <td style="border-top: 1px solid black;border-left: 0px;border-right: 0px;"></td>
                            <td style="border-top: 1px solid black;border-left: 0px;border-right: 0px;" v-for="(ite, ind) in jbPersonList" :key="ind"></td>
                            <td class="main-print-col12 textCenterPrint main-print-border-top-left">限额合计：</td>
                            <td class="main-print-col12 textCenterPrint main-print-border-top-left">实际发生合计：</td>
                            <td class="main-print-col12 textLeftPrint main-print-border-top-left main-print-border-right"></td>
                        </tr>
                        <tr>
                            <td class="main-print-col12 textCenterPrint main-print-border-top-left">合计</td>
                            <td class="main-print-col12 textCenterPrint main-print-border-top-left"></td>
                            <td class="main-print-col12 textCenterPrint main-print-border-top-left" v-for="(ite, ind) in jbPersonList" :key="ind">{{ite.personTotalCost}}</td>
                            <td class="main-print-col12 textCenterPrint main-print-border-top-left">{{xehj}}</td>
                            <td class="main-print-col12 textCenterPrint main-print-border-top-left">{{sjhj}}</td>
                            <td class="main-print-col12 textLeftPrint main-print-border-top-left main-print-border-right"></td>
                        </tr>
                    </table>
                    
                </div>
            </el-form>
            <el-form v-for="file in itemFileList" :key="file.fileId" v-show="currentPrintTab===''+file.fileId">
                <iframe :src="fileViewURL + encodeURIComponent(httpUrl+file.filePath)" width="100%" height="300px"></iframe>
            </el-form>
        </el-scrollbar>
    </div>
</template>

<script>
import { getBasicData, getItemList,getItemMainList, getFileInfoByCash } from '@/api/product/cash';
import { timeLength } from '@/utils/index';

export default {
    name:"cashPrint",
    props:{
        currentPrintTab:{
            type:String
        },
        propCashId:{
            type: Number,
            default:1,
            required: true
        }
    },
    data(){
        return {
            httpUrl:window.location.protocol + "//" + window.location.host + process.env.VUE_APP_BASE_API,
            fileViewURL:this.GLOBAL_.fileViewURL,
            printBasicData:{},
            printDetailList:[],
            printMainList:[],
            cashTimeLength:"",//时长
            itemFileList:[],
            cfList:[],//餐费列表
            jbList:[],//加班列表
            jbPersonList:[],//加班人员列表(带每人总费用)
            hasCf:false,//是否有餐费
            hasJb:false,//是否有加班
            dinnerReasonOptions:{},//宴请原因
            mealTimeOptions:{},//餐时
            xehj:0,//限额合计
            sjhj:0//实际合计
        }
    },
    created() {
        this.printCash(this.propCashId);
    },
    watch: {
        propCashId:function(val) {
            this.printCash(val);
        }
    },
    methods: {
        printCash(cashId){
            this.getDicts("oa_reason_dinner").then(response => {
                this.dinnerReasonOptions = response.data;
                this.getDicts("oa_meal_time").then(response => {
                    this.mealTimeOptions = response.data;
                    this.getBasicPrintData(cashId);
                    this.getItemPrintList(cashId);
                    this.getItemMainPrintList(cashId);
                    this.getFileInfoByCash({cashId:cashId});
                });
            });          
        },
        getBasicPrintData(id) {
            getBasicData(id).then(response => {
                this.printBasicData = response.data;
                this.cashTimeLength = timeLength(this.printBasicData.cashTimeStart,this.printBasicData.cashTimeEnd);
            });
        },
        getItemPrintList(cashId){
            getItemList(cashId).then(response => {
                let rows = response.rows; 
                //生成餐费信息
                let cfList = [];
                let jbList = [];
                let jbPersonList = [];
                let jbPersonMap = new Map();
                for(let j=0;j<rows.length;j++){
                    if(rows[j].expenseContent == '3'){
                        let tmpDate = new Date(rows[j].costTime);
                        let y = tmpDate.getFullYear(); 
                        let m = tmpDate.getMonth()+1; 
                        this.printBasicData.cfMon = m;
                        let d = tmpDate.getDate(); 
                        d = d < 10 ? ('0' + d) : d;  
                        let xehj = 0;
                        if(rows[j].reasonForDinner=='1'){
                            //宴请原因加班
                            this.hasJb = true;
                            let bePersonNames = rows[j].bePersonName.split(',');
                            for(let k=0;k<bePersonNames.length;k++){
                                if(jbPersonMap.get( bePersonNames[k])){
                                    jbPersonMap.set(bePersonNames[k],jbPersonMap.get( bePersonNames[k])+15);
                                }else{
                                    jbPersonMap.set(bePersonNames[k],15);
                                }
                                xehj += 15;
                            }
                            this.sjhj += rows[j].expenseMoney;
                            jbList.push({
                                costTime2:m+'.'+d,
                                xehj:xehj,
                                expenseMoney:rows[j].expenseMoney,
                                bePersonName:rows[j].bePersonName,
                                mealTime:this.getMealTime(rows[j].mealTime)
                            });
                        }
                        //餐费
                        this.hasCf = true;
                        cfList.push({
                            index:j+1,
                            costTime:y+'.'+m+'.'+d,
                            costTime2:m+'.'+d,
                            xehj:xehj,
                            expenseMoney:rows[j].expenseMoney,
                            costCity:rows[j].costCity,
                            hotel:rows[j].hotel,
                            bePersonName:rows[j].bePersonName,
                            position:rows[j].position,
                            expenseRemark:rows[j].expenseRemark,
                            reasonForDinnerValue:rows[j].reasonForDinner,
                            reasonForDinner:this.getReasonForDinner(rows[j].reasonForDinner),
                            mealTime:this.getMealTime(rows[j].mealTime)
                        });
                        
                    }
                }
                this.cfList = cfList;
                for(let key of jbPersonMap.keys()){
                    jbPersonList.push({personName:key,personTotalCost:jbPersonMap.get(key)});
                    this.xehj += jbPersonMap.get(key);
                }
                this.jbPersonList = jbPersonList;
                this.jbList = jbList;
                const oldlentgh = rows.length;
                if(rows.length<6){
                    for(let i=1;i<6-oldlentgh;i++){
                        rows.push({});
                    }
                }
                this.printDetailList = rows;

            });
        },
        getReasonForDinner(value){
            let dinnerReasonOptions = this.dinnerReasonOptions;
            for(let i=0;i<dinnerReasonOptions.length;i++){
                if(dinnerReasonOptions[i].dictValue == value){
                    return dinnerReasonOptions[i].dictLabel;
                }
            }
            return '';
        },
        getMealTime(value){
            let mealTimeOptions = this.mealTimeOptions;
            for(let i=0;i<mealTimeOptions.length;i++){
                if(mealTimeOptions[i].dictValue == value){
                    return mealTimeOptions[i].dictLabel;
                }
            }
            return '';
        },
        getItemMainPrintList(cashId){
            getItemMainList(cashId).then(response => {
                let rows = response.rows; 
                const oldlentgh = rows.length;
                if(rows.length<6){
                    for(let i=1;i<6-oldlentgh;i++){
                        rows.push({expenseMoney:''});
                    }
                }
                this.printMainList = rows;
            });
        },
        getFileInfoByCash(cashId) {
            getFileInfoByCash(cashId).then(
                response => {
                    this.itemFileList = response.data;
                }
            );
        },
        myPrint(){
            //此样式同页面style里样式一致 start
            let cssText='<style type="text/css" >';
            cssText+='.main-print-border-top-left{';
            cssText+='border-top: 1px solid black;';
            cssText+='border-left: 1px solid black;';
            cssText+='}';
            cssText+='.main-print-border-bottom{';
            cssText+='  border-bottom: 1px solid black;';
            cssText+='}';
            cssText+='.main-print-border-right{';
            cssText+='  border-right: 1px solid black;';
            cssText+='}';
             cssText+='.main-print-col10{';
            cssText+='  height:30px;';
            cssText+='  font-size:10px;';
            cssText+='  font-family:"宋体";';
            cssText+='  line-height:30px;';
            cssText+='}';
            cssText+='.main-print-col12{';
            cssText+='  height:30px;';
            cssText+='  font-size:12px;';
            cssText+='  font-family:"宋体";';
            cssText+='  line-height:30px;';
            cssText+='}';
            cssText+='.main-print-col16{';
            cssText+='  height:30px;';
            cssText+='  font-size:16px;';
            cssText+=' font-family:"宋体";';
            cssText+='  line-height:30px;';
            cssText+='}';
            cssText+='.textCenterPrint {';
            cssText+='  text-align:center;';
            cssText+='}';
            cssText+='.textLeftPrint {';
            cssText+='  padding-left:3px;';
            cssText+='}';
            cssText+='.printBottomDiv{';
            cssText+='  width:50%;';
            cssText+='  height:60px;';
            cssText+='  float:left;';
            cssText+='  line-height: 80px;';
            cssText+='  font-family:"宋体";';
            cssText+='  font-size:16px;';
            cssText+='}';
            cssText+='.printBottomMainDiv{';
            cssText+='  height:60px;';
            cssText+='  float:left;';
            cssText+='  line-height: 50px;';
            cssText+='  font-family:"宋体";';
            cssText+='  font-size:12px;}';
            if(this.currentPrintTab == 'jb'){
                cssText += "@page {size:landscape;}";
                cssText+='</style>';
            }else{
                cssText+='</style>';
            }
            //此样式同页面style里样式一致 end
            if(this.currentPrintTab == 'main'){
                this.printMain(cssText);
            }else if(this.currentPrintTab == 'mx'){
                this.printMx(cssText);
            }else if(this.currentPrintTab == 'cf'){
                this.printCf(cssText);
            }else if(this.currentPrintTab == 'jb'){  
                this.printJb(cssText);
            }
        },
        printMain(cssText){
            //打印主信息start
            let printMainHtml =  "<div style=\"width:100%;height:120px;\"></div>"+window.document.getElementById("mainPrintDiv").innerHTML ;
            var mainWindow = window.open("","main","height=600");
            mainWindow.document.write(cssText+printMainHtml); 
            mainWindow.document.close();
            mainWindow.focus();
            mainWindow.print();
            mainWindow.close();
            //打印主信息end
        },
        printMx(cssText){ 
            //打印明细start
            let printMxHtml = "<div style=\"width:100%;height:140px;\"></div>"+window.document.getElementById("mxPrintDiv").innerHTML;
            var mxWindow = window.open("","mx","height=600"); 
            mxWindow.document.write(cssText+printMxHtml); 
            mxWindow.document.close();
            mxWindow.focus();
            mxWindow.print();
            mxWindow.close();
            //打印明细end
        },
        printCf(cssText){ 
            //打印明细start
            let printCfHtml = "<div style=\"width:100%;height:140px;\"></div>"+window.document.getElementById("cfPrintDiv").innerHTML;
            var cfWindow = window.open("","cf","height=600"); 
            cfWindow.document.write(cssText+printCfHtml); 
            cfWindow.document.close();
            cfWindow.focus();
            cfWindow.print();
            cfWindow.close();
            //打印明细end
        },
        printJb(cssText){ 
            //打印明细start
            let printJbHtml = "<div style=\"width:100%;height:140px;\"></div>"+window.document.getElementById("jbPrintDiv").innerHTML;
            var jbWindow = window.open("","jb","height=600"); 
            jbWindow.document.write(cssText+printJbHtml); 
            jbWindow.document.close();
            //let RegWsh = new ActiveXObject("WScript.Shell");
            //RegWsh.sendKeys("%fu");
            //RegWsh.sendKeys("%a");
            //RegWsh.sendKeys("{ENTER}");
            //WebBrowser.execwb(8, 1); //弹出打印设置
            jbWindow.focus();
            jbWindow.print();
            jbWindow.close();
            //打印明细end
        }
    }
}
</script>

<style>
  .main-print-border-top-left{
    border-top: 1px solid black;
    border-left: 1px solid black;
  }
  .main-print-border-bottom{
    border-bottom: 1px solid black;
  }
  .main-print-border-right{
    border-right: 1px solid black;
  }
  .main-print-col10{
    height:30px;
    font-size:10px;
    font-family:"宋体";
    line-height:30px;
  }
  .main-print-col12{
    height:30px;
    font-size:12px;
    font-family:"宋体";
    line-height:30px;
  }
  .main-print-col16{
    height:30px;
    font-size:16px;
    font-family:"宋体";
    line-height:30px;
  }
  .textCenterPrint {
    text-align:center;
  }
  .textLeftPrint {
    padding-left:3px;
  }
  .printBottomDiv{
    width:50%;
    height:60px;
    float:left;
    line-height: 80px;
    font-family:"宋体";
    font-size:16px;
  }
  .printBottomMainDiv{
    height:60px;
    float:left;
    line-height: 50px;
    font-family:"宋体";
    font-size:12px;
  }
</style>